using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
namespace DAL
{
    public class TaggedPictures : DAL.DataManager<TaggedPicture>
    {
        private static TaggedPictures Instance = new TaggedPictures();
        static TaggedPictures() { }

        public override string TableName
        {
            get { return @"awesome_tagged_pictures"; }
        }

        protected override void CopyToItem(DataRow Row, TaggedPicture Item)
        {
            Item.Tag = Tags.Item(Convert.ToInt64(Row["TagID"]));

            Item.Picture = Photos.Item(Convert.ToInt64(Row["PictureID"]));
        }

        protected override void CopyFromItem(DataManagerQuery query, TaggedPicture Item)
        {
            query.AddParam("TagID", Item.Tag.ID);

            query.AddParam("PictureID", Item.Picture.ID);
        }

        public static TaggedPicture Item(Int64 id)
        {
            return Instance.GetItem(id);
        }

        public static List<TaggedPicture> All()
        {
            return Instance.GetItems();
        }

        public static void Add(TaggedPicture Item)
        {
            Instance.Insert(Item);
        }

        public static void Save(TaggedPicture Item)
        {
            Instance.Update(Item);
        }
    }

    public class TaggedPicture : DAL.DataManagerRow
    {
        private Tag _Tag;
        public Tag Tag
        {
            get
            {
                return _Tag;
            }
            set
            {
                _Tag = value;
            }
        }

        private Photo _Picture;
        public Photo Picture
        {
            get
            {
                return _Picture;
            }
            set
            {
                _Picture = value;
            }
        }
    }
}